package com.baizhi.cmfz.service.impl;

import com.baizhi.cmfz.mapper.CmfzShiroMapper;
import com.baizhi.cmfz.service.CmfzShiroService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Service
@Transactional
public class CmfzShiroServiceImpl implements CmfzShiroService {
    @Autowired
    private CmfzShiroMapper chm;

    @Override
    public Set<String> selectRoleNameByUsername(String username) {
        List<String> roles = chm.selectRoleByUserName(username);
        Set<String> roleSet = new HashSet<String>(roles);
        return roleSet;
    }

    @Override
    public Set<String> selectPermissionByUsername(String username) {
        List<String> permission = chm.selectResourceByUsername(username);
        Set<String> hashSet = new HashSet<>(permission);
        return hashSet;
    }
}
